﻿using System;
using Informator.Presentation.Common;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Informator.Presentation.Predmeti
{
    /// <summary>
    /// Interaction logic for Predmeti.xaml
    /// </summary>
    public partial class pgPredmeti : Page
    {
        public String pNaziv;
        String pSemestar;
        public int pGodina = 1;
        String pStudije;
        string dugme;
        Boolean IsClick = false;
        Frame f;
        public pgPredmeti()
        {
            InitializeComponent();
            DugmiciResponse();
            this.Loaded += (oo, ee) => 
            {
                Animate.SlideUp(this);
                //Animate.GridAnimateEntrance(Body);
                //Animate.GridAnimateEntrance(Heder);
                //Animate.GridAnimateEntrance(IzborSmera);
                //Animate.AddChildAnimate(btnNazad, Futer, 100);
            };
            NavigacijaEP.AddHandler(Button.ClickEvent, new RoutedEventHandler(Ep_Click));
            NavigacijaRt.AddHandler(Button.ClickEvent, new RoutedEventHandler(Rt_Click));
            NavigacijaNet.AddHandler(Button.ClickEvent, new RoutedEventHandler(Net_Click));
            NavigacijaElite.AddHandler(Button.ClickEvent, new RoutedEventHandler(Elite_Click));
            NavigacijaAvt.AddHandler(Button.ClickEvent, new RoutedEventHandler(Avt_Click));
            NavigacijaASV.AddHandler(Button.ClickEvent, new RoutedEventHandler(Asv_Click));
            NavigacijaNrt.AddHandler(Button.ClickEvent, new RoutedEventHandler(Nrt_Click));
        }

        private void DugmiciResponse()
        {
            foreach (var tmp in NavigacijaNrt.Children.Cast<UIElement>())
            {
                (tmp as Button).Click += (oo, ee) => { Animate.ElementResponse(oo as UIElement); };
            }
            foreach (var tmp in NavigacijaASV.Children.Cast<UIElement>())
            {
                (tmp as Button).Click += (oo, ee) => { Animate.ElementResponse(oo as UIElement); };
            }
            foreach (var tmp in NavigacijaAvt.Children.Cast<UIElement>())
            {
                (tmp as Button).Click += (oo, ee) => { Animate.ElementResponse(oo as UIElement); };
            }
            foreach (var tmp in NavigacijaElite.Children.Cast<UIElement>())
            {
                (tmp as Button).Click += (oo, ee) => { Animate.ElementResponse(oo as UIElement); };
            }
            foreach (var tmp in NavigacijaEP.Children.Cast<UIElement>())
            {
                (tmp as Button).Click += (oo, ee) => { Animate.ElementResponse(oo as UIElement); };
            }
            foreach (var tmp in NavigacijaNet.Children.Cast<UIElement>())
            {
                (tmp as Button).Click += (oo, ee) => { Animate.ElementResponse(oo as UIElement); };
            }
            foreach (var tmp in NavigacijaRt.Children.Cast<UIElement>())
            {
                (tmp as Button).Click += (oo, ee) => { Animate.ElementResponse(oo as UIElement); };
            }
        }

        private void Ep_Click(object sender, RoutedEventArgs e)
        {
            var Godina = e.Source.ToString().Substring(32, 1);
            pGodina = Convert.ToInt16(Godina);
            pNaziv = "Еп";
            pgPredmetiIzbor pg = new pgPredmetiIzbor(pGodina, pNaziv);
            Animate.SlideDownPage(this, pg);
            btnDisable();
        }

        private void Rt_Click(object sender, RoutedEventArgs e)
        {

            var Godina = e.Source.ToString().Substring(32, 1);
            pGodina = Convert.ToInt16(Godina);
            pNaziv = "Рт";
            pgPredmetiIzbor pg = new pgPredmetiIzbor(pGodina, pNaziv);
            Animate.SlideDownPage(this, pg);
            btnDisable();
        }

        private void Net_Click(object sender, RoutedEventArgs e)
        {
            var Godina = e.Source.ToString().Substring(32, 1);
            pGodina = Convert.ToInt16(Godina);
            pNaziv = "Нет";
            pgPredmetiIzbor pg = new pgPredmetiIzbor(pGodina, pNaziv);
            Animate.SlideDownPage(this, pg);
            btnDisable();
        }

        private void Elite_Click(object sender, RoutedEventArgs e)
        {
            var Godina = e.Source.ToString().Substring(32, 1);
            pGodina = Convert.ToInt16(Godina);
            pNaziv = "Елите";
            pgPredmetiIzbor pg = new pgPredmetiIzbor(pGodina, pNaziv);
            Animate.SlideDownPage(this, pg);
            btnDisable();
        }

        private void Avt_Click(object sender, RoutedEventArgs e)
        {
            var Godina = e.Source.ToString().Substring(32, 1);
            pGodina = Convert.ToInt16(Godina);
            pNaziv = "Авт";
            pgPredmetiIzbor pg = new pgPredmetiIzbor(pGodina, pNaziv);
            Animate.SlideDownPage(this, pg);
            btnDisable();
        }

        private void Asv_Click(object sender, RoutedEventArgs e)
        {
            var Godina = e.Source.ToString().Substring(32, 1);
            pGodina = Convert.ToInt16(Godina);
            pNaziv = "Асув";
            pgPredmetiIzbor pg = new pgPredmetiIzbor(pGodina, pNaziv);
            Animate.SlideDownPage(this, pg);
            btnDisable();
        }

        private void Nrt_Click(object sender, RoutedEventArgs e)
        {
            string Godina = e.Source.ToString().Substring(32, 1);
            pGodina = Convert.ToInt16(Godina);
            pNaziv = "Нрт";
            pgPredmetiIzbor pg = new pgPredmetiIzbor(pGodina, pNaziv);
            Animate.SlideDownPage(this, pg);
            btnDisable();
        }


        private void btnNazad_Click(object sender, RoutedEventArgs e)
        {
            Animate.SlideDownBack(this);
            Animate.ElementResponse(btnNazad);
            btnDisable();
        }

        private void btnDisable()
        {
            btnNazad.IsHitTestVisible = false;
            btnAsuv1.IsHitTestVisible = false;
            btnAsuv2.IsHitTestVisible = false;
            btnAsuv3.IsHitTestVisible = false;
            btnAvt1.IsHitTestVisible = false;
            btnAvt2.IsHitTestVisible = false;
            btnAvt3.IsHitTestVisible = false;
            btnЕlite1.IsHitTestVisible = false;
            btnElite2.IsHitTestVisible = false;
            btnElite3.IsHitTestVisible = false;
            btnEp1.IsHitTestVisible = false;
            btnEp2.IsHitTestVisible = false;
            btnEp3.IsHitTestVisible = false;
            btnNet1.IsHitTestVisible = false;
            btnNet2.IsHitTestVisible = false;
            btnNet3.IsHitTestVisible = false;
            btnNrt1.IsHitTestVisible = false;
            btnNrt2.IsHitTestVisible = false;
            btnNrt3.IsHitTestVisible = false;
            btnRt1.IsHitTestVisible = false;
            btnRt2.IsHitTestVisible = false;
            btnRt3.IsHitTestVisible = false;
        }

        public void btnEnable()
        {
            btnNazad.IsHitTestVisible = true;
            btnAsuv1.IsHitTestVisible = true;
            btnAsuv2.IsHitTestVisible = true;
            btnAsuv3.IsHitTestVisible = true;
            btnAvt1.IsHitTestVisible = true;
            btnAvt2.IsHitTestVisible = true;
            btnAvt3.IsHitTestVisible = true;
            btnЕlite1.IsHitTestVisible = true;
            btnElite2.IsHitTestVisible = true;
            btnElite3.IsHitTestVisible = true;
            btnEp1.IsHitTestVisible = true;
            btnEp2.IsHitTestVisible = true;
            btnEp3.IsHitTestVisible = true;
            btnNet1.IsHitTestVisible = true;
            btnNet2.IsHitTestVisible = true;
            btnNet3.IsHitTestVisible = true;
            btnNrt1.IsHitTestVisible = true;
            btnNrt2.IsHitTestVisible = true;
            btnNrt3.IsHitTestVisible = true;
            btnRt1.IsHitTestVisible = true;
            btnRt2.IsHitTestVisible = true;
            btnRt3.IsHitTestVisible = true;
        }
    }
}
